package com.zkingsoft.zkingbase.activities;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.zkingsoft.picbroswer.ActivityCode;
import com.zkingsoft.picbroswer.AlbumActivity;
import com.zkingsoft.rxbus.annotation.Subscribe;
import com.zkingsoft.rxbus.annotation.Tag;
import com.zkingsoft.rxbus.thread.EventThread;
import com.zkingsoft.zkingbase.R;
import com.zkingsoft.zkingbase.base.BaseActivity;
import com.zkingsoft.zkingbase.bean.AppVersion;
import com.zkingsoft.zkingbase.bean.User;
import com.zkingsoft.zkingbase.constant.Constant;
import com.zkingsoft.zkingbase.engine.UpdateEngine;
import com.zkingsoft.zkingbase.manager.GreenDaoManager;
import com.zkingsoft.zkingbase.utils.FileUtils;
import com.zkingsoft.zkingbase.utils.PreferenceUtils;

import java.util.List;

import butterknife.OnClick;

public class MainActivity extends BaseActivity
{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getContentView()
    {
        return R.layout.activity_main;
    }

    @OnClick({R.id.btn_login, R.id.btn_pay, R.id.btn_share, R.id.btn_push})
    public void onClick(View view)
    {
        switch (view.getId())
        {
            case R.id.btn_login:
                if((Boolean)PreferenceUtils.get(Constant.FLAG_IS_LOGIN, false))
                {
                    GreenDaoManager manager = GreenDaoManager.getInstance(this, "appdb.db");
                    List<User> l = manager.getDaoSession().getUserDao().loadAll();
                    if(l != null && l.size() >0)
                    {
                        Intent intent = new Intent(this, InfoActivity.class);
                        intent.putExtra("userinfo", l.get(0));
                        startActivity(intent);
                    }
                }else
                {
                    startActivity(new Intent(this, LoginActivity.class));
                }
                break;
            case R.id.btn_pay:
                startActivity(new Intent(this, PayActivity.class));
                break;
            case R.id.btn_share:
                startActivity(new Intent(this, ShareActivity.class));
                break;
            case R.id.btn_push:
                startActivity(new Intent(this, PushActivity.class));
                break;
        }
    }
}
